# Maintainer: gym603 <gui_yuan_miao@163.com>

_realname=keras_preprocessing
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.1.0
pkgrel=2
pkgdesc="Utilities for working with image data, text data, and sequence data. (mingw-w64)"
arch=('any')
url="https://github.com/keras-team/keras-preprocessing"
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
_archive=${_realname/_/-}-${pkgver}
source=(${_archive}.tar.gz::https://github.com/keras-team/keras-preprocessing/archive/${pkgver}.tar.gz)
sha256sums=('26f26354370f4a08a029137630d72870e99e924cd8f6e04c2f6fc0bd86708275')

_deps=('numpy' 'six')

build() {
  cd "${srcdir}"
  rm -rf python{2,3}-build
  for builddir in python{2,3}-build; do
    msg2 "Building for ${CARCH} ${builddir%-build} ..."
    cp -r ${_archive} ${builddir}
    pushd $builddir
    ${MINGW_PREFIX}/bin/${builddir%-build} setup.py --quiet build
    popd
  done
}

package_python3-keras_preprocessing() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3" "${_deps[@]/#/${MINGW_PACKAGE_PREFIX}-python3-}")

  cd "${srcdir}/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python3 setup.py --quiet install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-keras_preprocessing() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2" "${_deps[@]/#/${MINGW_PACKAGE_PREFIX}-python2-}")

  cd "${srcdir}/python2-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py --quiet install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-keras_preprocessing() {
  package_python2-keras_preprocessing
}

package_mingw-w64-i686-python3-keras_preprocessing() {
  package_python3-keras_preprocessing
}

package_mingw-w64-x86_64-python2-keras_preprocessing() {
  package_python2-keras_preprocessing
}

package_mingw-w64-x86_64-python3-keras_preprocessing() {
  package_python3-keras_preprocessing
}
